# -*- encoding: utf-8 -*-
'''
@File    :   err_analyze.py
@Time    :   2021/11/22 15:33
@Author  :   ZhangChaoYang
@Desc    :   
'''


def fit_err_percentage(X, X_hat, err_func):
    errors = err_func(X, X_hat).numpy().tolist()
    sl = sorted(errors)
    print("拟合误差分位点")
    rect = []
    for p in range(0, 100, 5):
        index = int(p / 100.0 * len(sl))
        print("{}%\t{:.2e}".format(p, sl[index]))
        rect.append(sl[index])
    print("100%\t{:.2e}".format(sl[-1]))
    # rect.append(sl[-1])
    return rect
